<template>
  <div class="index">
    <div class="left">
      <h2>酒店信息综合平台</h2>
      <el-menu router active-text-color="#ffd04b" background-color="#142332" class="el-menu-vertical-demo" default-active="2"
        text-color="#fff">
        <el-sub-menu index="1">
          <template #title>
            <el-icon>
              <User />
            </el-icon>
            <span>账号管理</span>
          </template>
          <el-menu-item index="/index/role">角色管理</el-menu-item>
          <el-menu-item index="/index/user">用户管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="2">
          <template #title>
            <el-icon>
              <DishDot />
            </el-icon>
            <span>客房管理</span>
          </template>
          <el-menu-item index="/index/roomType">房型管理</el-menu-item>
          <el-menu-item index="/index/room">房间管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="3">
          <template #title>
            <el-icon>
              <Goblet />
            </el-icon>
            <span>客户管理</span>
          </template>
          <el-menu-item index="/index/liveIn">入住管理</el-menu-item>
          <el-menu-item index="/index/order">客户订单</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="4">
          <template #title>
            <el-icon>
              <Tickets />
            </el-icon>
            <span>系统管理</span>
          </template>
          <el-menu-item index="/index/menu">菜单管理</el-menu-item>
          <el-menu-item index="/index/dictionary">字典订单</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </div>
    <div class="right">
      <div class="top">

        <el-menu router :ellipsis="false" mode="horizontal" background-color="#142332" text-color="#fff"
          active-text-color="#ffd04b">
          <el-menu-item index="/index/home">
            <el-icon>
              <HomeFilled />
            </el-icon>
            首页</el-menu-item>
          <el-menu-item index="/index/mail"><el-icon>
              <ChatLineSquare />
            </el-icon>邮件</el-menu-item>
          <el-menu-item index="/index/message"><el-icon>
              <Message />
            </el-icon>消息</el-menu-item>
          <el-sub-menu index="2">
            <template #title><el-icon>
                <Avatar />
              </el-icon>管理员</template>
            <el-menu-item index="/index/user">个人中心</el-menu-item>
            <el-menu-item index="/index/setPwd">修改密码</el-menu-item>
            <el-menu-item @click="exit">退出系统</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </div>
      <div class="content">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {
  User,
  DishDot,
  Goblet,
  Tickets,
  HomeFilled,
  Message,
  ChatLineSquare,
  Avatar
} from '@element-plus/icons-vue'
import { onMounted } from 'vue'
import useUser  from '../store/user'
import {useRouter} from 'vue-router';

const userStore = useUser()
const router = useRouter()

onMounted(()=> {
  if (!userStore.user.loginId) {
    router.push('/')
  }
})

const exit = ()=> {
  userStore.clearUser()
  router.push('/')
}

</script>

<style scoped lang="scss">
.index {
  width: 100vw;
  height: 100vh;
  display: flex;

  .left {
    width: 200px;
    background: #142332;
    color: #fff;

    h2 {
      font-size: 18px;
      text-align: center;
      height: 60px;
      line-height: 60px;
    }

    .el-menu {
      border-right: none;
    }
  }

  .right {
    flex: 1;
    display: flex;
    flex-direction: column;

    .top {
      height: 60px;
      background: #142332;
      color: #fff;
      display: flex;
      justify-content: flex-end;
      .el-menu {
        border-bottom: none;
      }
    }

    .content {
      flex: 1;
      background: #fff;
      padding: 5px;
    }
  }
}
</style>
